4 // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
6 // The use and distribution terms for this software are contained in the file
7 // named license.txt, which can be found in the root of this distribution.
8 // By using this software in any fashion, you are agreeing to be bound by the
9 // terms of this license.
11 // You must not remove this notice, or any other, from this software.
16 // This tool generates the unicode_data.c file which contains the unicode data table
22 CONST
char copyright_header
[] =
25 "// Copyright (c) Microsoft Corporation. All rights reserved.\n"
29 "// This file is generated by rotor/tools/genpalunitable.\n"
31 "#include \"pal/unicode_data.h\"\n"
33 "CONST UnicodeDataRec UnicodeData[] =\n"
36 /* If we need the description of unicode chars in unicode_data.c, then we just
37 have to set UnicodeDataStrings table with all wchars description strings */
38 char* UnicodeDataStrings
[] = {""};
40 int __cdecl
main(int argc
, char *argv
[])
51 CONST UINT LAST_DIRECT_ACCESS
= 256;
53 if (!(fpOut
= fopen("unicode_data.c", "w")))
55 printf("Unable to open unicode_data.c for write\n");
59 fprintf(fpOut
, "%s", copyright_header
);
61 for (i
=0; i
< 0xFFFF; i
++)
63 if (!GetStringTypeExW(LOCALE_USER_DEFAULT
, CT_CTYPE1
,
64 (WCHAR
*)&i
, 1, &Info
))
67 "GetStringTypeExW failed to get information for %#X!\n", i
);
71 oppC
= iswupper(i
) ? towlower(i
) : (iswlower(i
) ? towupper(i
) : 0);
73 /* Print out all 256 first chars */
74 if (i
<= LAST_DIRECT_ACCESS
)
76 fprintf(fpOut
, "{ 0x%04x,\t0x%04x,\t0x%04x,\t%d },\t\t%s\n",
77 i
, Info
, oppC
, 0, UnicodeDataStrings
[/*i*/0]);
81 if ((oppC
!= 0) || (Info
!= 0))
83 /* We don't need to print out all chars with the same C1_TYPE
84 and with the same opposite char */
85 if ((oppC
== oppCout
) && (Info
== InfoOut
))
88 fprintf(fpOut
, "/*0x%04x,\t0x%04x,\t0x%04x,\t%d } */\t\t%s\n",
89 i
, Info
, oppC
, 0, UnicodeDataStrings
[/*i*/ 0]);
96 fprintf(fpOut
, "{ 0x%04x,\t0x%04x,\t0x%04x,\t%d },"
97 "\t\t%s\n", iOut
, InfoOut
, oppCout
, duplicate
,
98 UnicodeDataStrings
[/*iOut*/ 0]);
101 /* reset the next char to print out */
110 fprintf(fpOut
, "/*0x%04x,\t0x%04x,\t0x%04x,\t%d } */\t\t%s\n",
111 i
, Info
, oppC
, 0, UnicodeDataStrings
[/*i*/0]);
117 fprintf(fpOut
, "};\n\n");
118 fprintf(fpOut
, "CONST UINT UNICODE_DATA_SIZE = "
119 "sizeof(UnicodeData)/sizeof(UnicodeDataRec);\n");
120 fprintf(fpOut
, "CONST UINT UNICODE_DATA_DIRECT_ACCESS = %d;\n",